import { createRouter, createMemoryHistory } from 'vue-router'
// 使用相对地址引入路由组件
const router = createRouter({
  routes: [
    {
      path: '/',
      redirect: '/home',
      children: [
        {
          path: '/home',
          component: () => import('../views/home.vue'),
        },
        {
          path: '/index',
          component: () => import('../views/home.vue'),
        },
      ],
    },
  ],
  history: createMemoryHistory(),
})

router.beforeEach((to, from, next) => {
  console.log('[ from ]', from)

  console.log('[ beforeEach-to ]', to)
  next()
})
export default router
